package tasks.OpportunitiesBaseData.ManualUpdateView.ContextualData;
import resources.tasks.OpportunitiesBaseData.ManualUpdateView.ContextualData.DropDownsVerifierHelper;
import tasks.Brand;
import tasks.LayoutOps.Mapping;
import tasks.LayoutOps.Wrapper;
import tasks.OpportunitiesBaseData.Pattern;

import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.object.interfaces.SAP.*;
import com.rational.test.ft.object.interfaces.WPF.*;
import com.rational.test.ft.object.interfaces.dojo.*;
import com.rational.test.ft.object.interfaces.siebel.*;
import com.rational.test.ft.object.interfaces.flex.*;
import com.rational.test.ft.object.interfaces.generichtmlsubdomain.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
import com.ibm.rational.test.ft.object.interfaces.sapwebportal.*;

import core.ControlsMapping;
import core.exceptions.ResultFailureException;
/**
 * Description   : Functional Test Script
 * @author angel.tsvetkov
 */
public class DropDownsVerifier extends DropDownsVerifierHelper
{
	public boolean verifySTG(String dtlKey)
	{
		Wrapper wrapper = new Wrapper(
	    		new Mapping("Rep Input", ControlsMapping.ManualUpdateView.DropDownsArea.repInput_staticText),
	    		new Mapping("Route to Market", ControlsMapping.ManualUpdateView.DropDownsArea.routeToMarket_selectBox),
	    		new Mapping("Primary Channel", ControlsMapping.ManualUpdateView.DropDownsArea.primaryChannel_selectBox),
	    		new Mapping("BP Role", ControlsMapping.ManualUpdateView.DropDownsArea.bpRole_selectBox),
	    		new Mapping("Customer Facing", ControlsMapping.ManualUpdateView.DropDownsArea.customerFacing_selectBox),
	    		new Mapping("Status", ControlsMapping.ManualUpdateView.DropDownsArea.status_selectBox),
	    		new Mapping("Build Ahead", ControlsMapping.ManualUpdateView.DropDownsArea.buildAhead_selectBox),
	    		new Mapping("Lost Analysis", ControlsMapping.ManualUpdateView.DropDownsArea.lostAnalysis_selectBox),
	    		new Mapping("Duplicate Opportunity", ControlsMapping.ManualUpdateView.DropDownsArea.duplicateOpportunity_selectBox),
	    		new Mapping("Delegate Seller", ControlsMapping.ManualUpdateView.DropDownsArea.delegateSeller_selectBox),
	    		new Mapping("Expected Close Date", ControlsMapping.ManualUpdateView.DropDownsArea.expectedCloseDate_textField),
	    		new Mapping("Expected Close Week", ControlsMapping.ManualUpdateView.DropDownsArea.expectedCloseWeek_textField),
	    		new Mapping("Expected Close Qtr", ControlsMapping.ManualUpdateView.DropDownsArea.expectedCloseQuarter_textField),
	    		new Mapping("iBSS Revenue View", ControlsMapping.ManualUpdateView.DropDownsArea.iBSSRevenue_textField),
	    		new Mapping("PO Number", ControlsMapping.ManualUpdateView.DropDownsArea.poNumber_textField),
	    		new Mapping("Next Action Date", ControlsMapping.ManualUpdateView.DropDownsArea.nextActionDate_textField)
	    		);
	    
	    return verifier(wrapper, Brand.STG, dtlKey);
	}
	
	public boolean verify(Brand brand, String dtlKey)
	{
		boolean result = false;
		
		switch (brand) 
		{
			case STG:
			{
				verifySTG(dtlKey);
			}break;

			case ITS:
			{
				
			}break;
		}
		return result;
	}
	
	private boolean verifier(Wrapper wrapper, Brand brand, String dtlKey)
	{
		boolean result = false;
		String testActions = "";
		    
	    try {
	    	
	    	testActions = "\n Get data from the front end.";
	    	wrapper.wrapFrontEnd();
	    	
	    	testActions += "\n Get data from the database.";
	    	wrapper.wrapDatabase("ManualUpdate\\STGDropDowns.sql", new Pattern("%BRAND%", brand.name()), new Pattern("%OPP_DTL_KEY%", dtlKey));
			
			testActions += "Compare front end data and data from the database.";
			if(wrapper.compare())
			{
				result = true;
			}
		
	    } catch (ResultFailureException e) {
			e.printStackTrace();
			setErrorComment(e.getError());
		}
	    setTaskResult("TASK: Verify Manual Update Contextual Data in the front edd and database for " + brand + " brand.", result, testActions);
	    return result;
	}
}

